<template>
  <div class="content">
    <div class="titletopXX">
      <van-nav-bar
        size="30"
        :title="title"
        left-arrow
        right-text=""
        :fixed="true"
        @click-left="onClickLeft"
      />
    </div>
    <div class="basicInfo">
      <div style="display: flex; justify-content: space-between; align-items: center">
        <div class="title">基本信息</div>
        <van-image
          v-if="dataInfo.orderStatus == 0"
          radius="4"
          class="img"
          :src="require('../../../imgs/SY.png')"
          width="67px"
          height="21px"
          mode="widthFix"
        ></van-image>
        <van-image
          v-if="dataInfo.orderStatus == -1"
          radius="4"
          class="img"
          :src="require('../../../imgs/QX.png')"
          width="67px"
          height="21px"
          mode="widthFix"
        ></van-image>
        <van-image
          v-if="dataInfo.orderStatus == 2"
          radius="4"
          class="img"
          :src="require('../../../imgs/SH.png')"
          width="67px"
          height="21px"
          mode="widthFix"
        ></van-image>
        <van-image
          v-if="dataInfo.orderStatus == 1"
          radius="4"
          class="img"
          :src="require('../../../imgs/WC.png')"
          width="67px"
          height="21px"
          mode="widthFix"
        ></van-image>
      </div>
      <div style="font-size: 16px">
        <div style="display: flex; justify-content: space-between">
          <span>单位/部室</span
          ><span style="font-size: 14px">{{ dataInfo.detailList[0].unit }}</span>
        </div>
        <div style="margin: 10px 0; display: flex; justify-content: space-between">
          <span>一级部署编号</span
          ><span style="font-size: 14px">{{ dataInfo.detailList[0].number }}</span>
        </div>
        <div style="margin-bottom: 5px">出行人员</div>
        <div
          v-for="item in dataInfo.detailList[0].convalesceAndEntouragesList"
          :key="item.id"
          class="item_list"
        >
          <div>
            <span>{{ item.employeeName }}/{{ item.gender }} 【{{ item.relationship }}】</span>
          </div>
          <div class="item_list_info">
            <span>手机号：</span> <span>{{ item.contactInfo }}</span>
          </div>
          <div class="item_list_info">
            <span>身份证号：</span> <span>{{ item.idCard }}</span>
          </div>
        </div>
      </div>
    </div>
    <div class="basicInfo">
      <div class="title">疗休养信息</div>
      <div class="basicInfo_item">
        <span>疗养地</span><span>{{ dataInfo.detailList[0].destination }}</span>
      </div>
      <div class="basicInfo_item">
        <span>疗休养类型</span><span>{{ dataInfo.detailList[0].convalesceType }}</span>
      </div>
      <div class="basicInfo_item">
        <span>出行时间</span><span>{{ dataInfo.detailList[0].travelDate }}</span>
      </div>
      <div class="basicInfo_item">
        <span>上次疗休养时间</span><span>{{ dataInfo.detailList[0].lastConvalesceDate }}</span>
      </div>
    </div>
    <div class="basicInfo">
      <div class="title">其它</div>
      <div class="basicInfo_item">
        <span>备注</span><span>{{ dataInfo.detailList[0].remark }}</span>
      </div>
    </div>
    <div class="basicInfo" v-if="dataInfo.orderEvaluateApproval">
      <div class="title">审核记录</div>
      <div class="basicInfo_item">
        <span>审批人</span><span>{{ dataInfo.orderEvaluateApproval.creator }}</span>
      </div>
      <div class="basicInfo_item">
        <span>审批时间</span><span>{{ dataInfo.orderEvaluateApproval.creationTime }}</span>
      </div>
      <div class="basicInfo_item">
        <span>审批操作</span><span>{{ dataInfo.orderEvaluateApproval.content }}</span>
      </div>
    </div>
    <div class="basicInfo">
      <div class="title">审批意见</div>
      <div v-if="!dataInfo.verification">
        <van-field type="textarea" v-model="formData.content" placeholder="请输入审批意见" />
      </div>
      <div v-else style="text-align: center; color: #999; font-size: 14px">暂无审批意见</div>
    </div>
    <div
      style="display: flex; justify-content: space-between; margin: 10px 0"
      v-if="!dataInfo.verification"
    >
      <van-button round block color="#F56C6C" @click="handleReject" style="margin-right: 10px">
        驳回申请
      </van-button>
      <van-button round block color="#36c2a8" @click="handleConfirm"> 同意申请 </van-button>
    </div>
    <div style="height: 10px;"></div>
  </div>
</template>

<script>
import { Dialog, Toast } from "vant"
import { addServiceOrderAdminApproval } from "@/api/realAssets/icsharedstation/LYDJ/index.js"
import { getandroidCode } from "../../../../common/auth";

export default {
  data () {
    return {
      dataInfo: {},
      siteData: JSON.parse(localStorage.getItem("siteData")),
      title: "疗休养审批详情",
      formData: {
        content: "",
        ishid: getandroidCode(),
        orderId: decodeURIComponent(this.$route.query.LYSPDB).id,
        score: ""
      }
    }
  },
  methods: {
    onClickLeft () {
      this.$router.back()
    },
    handleReject () {
      Dialog.confirm({
        title: "提示",
        message: "确定要驳回申请吗？"
      })
        .then(() => {
          this.formData.score = "0"
          addServiceOrderAdminApproval(this.formData).then((res) => {
            if (res.resultMessage == "SUCCESS") {
              Toast.fail({
                message: "驳回申请成功",
                duration: 1000
              })
              this.$router.back()
            }
          })
        })
        .catch(() => {
          // on cancel
        })
    },
    handleConfirm () {
      Dialog.confirm({
        title: "提示",
        message: "确定要同意申请吗？"
      })
        .then(() => {
          this.formData.value.score = "1"
          addServiceOrderAdminApproval(this.formData.value).then((res) => {
            if (res.resultMessage == "SUCCESS") {
              Toast.success({
                message: "同意申请成功",
                duration: 1000
              })
              this.$router.back()
            }
          })
        })
        .catch(() => {})
    }
  },
  mounted () {
    this.dataInfo = JSON.parse(decodeURIComponent(this.$route.query.LYSPDB))
    this.formData.orderId = decodeURIComponent(this.$route.query.LYSPDB).id
  }
}
</script>

<style lang="less" scoped>
.content {
  background-color: #f8fbff;
  // min-height: 100vh !important;
  padding: 20px;
}
.title {
  font-size: 16px;
  font-weight: 500;
  color: #00baad;
  margin-bottom: 10px;
}
.item_list {
  margin-bottom: 10px;
  padding: 0 0 0 10px;
  font-size: 12px;
}
.item_list_info {
  display: flex;
  justify-content: space-between;
  padding: 5px 0;
}
.basicInfo {
  margin-top: 10px;
}
.basicInfo_item {
  display: flex;
  justify-content: space-between;
  padding: 5px 0;
  font-size: 14px;
}
.van_tab {
  --van-tabs-bottom-bar-color: #36c2a8;
}
.titletopXX {
  height: 45px;
}
</style>
